Skip to content

Complete the Protocol Descriptor as the single home for per-protocol knowledge#37

Merged
mibrahimdev merged 2 commits into
developfrom
feat/complete-protocol-descriptor
Jun 17, 2026
Merged

Complete the Protocol Descriptor as the single home for per-protocol knowledge#37
mibrahimdev merged 2 commits into
developfrom
feat/complete-protocol-descriptor

Conversation

@mibrahimdev

Copy link
Copy Markdown
Owner

What

Finishes the ProtocolDescriptor so it is genuinely "the single home for everything Sharingan knows about one Protocol" (CONTEXT.md). Two per-protocol facts and one fragile counts-line were still living outside it; this brings them home. 100% internal — no public API / :sharingan-noop change, so apiCheck/parity are unaffected.

Found via the architecture review (the descriptor is already a deep module; these were the last leaks at its edges).

Two commits, two seams

1. fix(export) — unify the counts line (latent bug).
SharinganExport.countsLine() hardcoded count { it is HttpEvent/MqttEvent/BleEvent } + a literal "HTTP h · MQTT m · BLE b" template, so a 4th protocol would be silently omitted from the session export header — while NotificationContent already iterated Protocol.entries. Extracted one internal protocolCountsLine() helper next to the Protocol registry and routed both callers through it. Output is byte-for-byte identical for today's three protocols (existing SharinganExportTest / NotificationContentTest stay green); a new protocol now appears automatically.

  • TDD: new EventFilterTest cases pin the format and assert one segment per Protocol.entries (the regression guard).

2. refactor(ui) — move tab icon + search placeholder onto the descriptor.
The tab-bar icon and search-field placeholder were the last two per-protocol facts resolved by when (protocol) blocks in HomeScreen. Lifted to abstract tabIcon / searchPlaceholder members; the two whens collapse to descriptorOf(protocol).tabIcon / .searchPlaceholder. The compiler now forces every descriptor to supply both.

Note on "session"

The counts helper is deliberately named protocolCountsLine (not session*) and introduces no Session term — that name is reserved for the v2 persistence epic (#27), where Session becomes a persisted, identified capture run. The helper is a pure fold over a List<SharinganEvent>, so it's reusable for rendering a loaded Session header later.

Verification

  • :sharingan:testDebugUnitTest + :sharingan-noop:testDebugUnitTest green; :sharingan:compileKotlinIosSimulatorArm64 green.
  • Leakage re-check: no when (protocol) remains outside ProtocolDescriptor; the hardcoded counts literal is gone.

Net

Adding a protocol now touches one place (the descriptor), and the type system enforces it.

🤖 Generated with Claude Code

mibrahimdev and others added 2 commits June 17, 2026 21:39
SharinganExport.countsLine() hardcoded three `count { it is X }` calls and a
literal "HTTP h · MQTT m · BLE b" template, so a fourth protocol would be
silently omitted from the session export header — while NotificationContent
already iterated Protocol.entries. Extract one internal protocolCountsLine()
helper next to the Protocol registry (EventFilter.kt) and route both callers
through it. Output is byte-for-byte identical for the three current protocols
(SharinganExportTest / NotificationContentTest stay green); a new protocol now
appears in the export header automatically.

TDD: EventFilterTest pins the format and asserts one segment per
Protocol.entries (red -> green).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…iptor

Completes the descriptor as the single home for per-protocol knowledge. The
tab-bar icon and the search-field placeholder were the last two per-protocol
facts resolved by `when (protocol)` blocks inside HomeScreen; lift them to
abstract tabIcon / searchPlaceholder members on ProtocolDescriptor, implemented
by each descriptor, and collapse the two HomeScreen `when`s to
descriptorOf(protocol).tabIcon / .searchPlaceholder. Adding a protocol now
touches one place and the compiler forces both members to be supplied.
Internal-only; no public API or noop change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mibrahimdev mibrahimdev merged commit 9b26686 into develop Jun 17, 2026
4 checks passed
@mibrahimdev mibrahimdev deleted the feat/complete-protocol-descriptor branch June 17, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant